import {
	createRouter,
	createWebHistory,
	createWebHashHistory
} from 'vue-router'
const routes = [{
		path: '/',
		redirect: '/home',
		component: () => import("@/view/home/home.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '网站首页',
		}
	},
	{
		path: '/home',
		name: 'home',
		component: () => import("@/view/home/home.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '网站首页'
		}
	},
	{
		path: '/map',
		name: 'map',
		component: () => import("@/view/map/map.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '站院地图'
		}
	},
	{
		path: '/job',
		name: 'job',
		component: () => import("@/view/job/job.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '工作动态'
		},
		children: [
			{
				path: 'jobmore',
				name: 'jobmore',
				component: () => import("@/view/job/jobmore.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '工作动态更多'
				}
			},
			{
				path: 'noticemore',
				name: 'jobnoticemore',
				component: () => import("@/view/job/noticemore.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '通知公告更多'
				}
			},
			{
				path: 'jobpolicymore',
				name: 'jobpolicymore',
				component: () => import("@/view/job/policymore.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '政策法规更多'
				}
			},
			{
				path: 'jobsciencemore',
				name: 'jobsciencemore',
				component: () => import("@/view/job/sciencemore.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '科学研究更多'
				}
			},
			{
				path: 'joblogmore',
				name: 'joblogmore',
				component: () => import("@/view/job/logmore.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '站院日志更多'
				}
			},

			{
				path: 'jobdetail/:id',
				name: 'jobdetail',
				component: () => import("@/view/job/jobdetail.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '工作动态详情'
				}
			},

			{
				path: 'jobdetail1/:id',
				name: 'jobdetail1',
				component: () => import("@/view/job/yardLogDetail1.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '工作动态详情'
				}
			},
		]
	},
	{
		path: '/specialist',
		name: 'specialist',
		component: () => import("@/view/specialist/specialist.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '专家队伍'
		},
		children: [
			{
				path: 'specialistDetail/:id',
				name: 'specialistDetail',
				component: () => import("@/view/specialist/specialistDetail.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '专家详情'
				}
			}
		]
	},
	{
		path: '/nsqa',
		name: 'nsqa',
		component: () => import("@/view/nsqa/nsqa.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '农事问答',
		},
		children: [
			{
				path: 'nsqaDetail/:id',
				name: 'nsqaDetail',
				component: () => import("@/view/nsqa/nsqaDetail.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '农事问答详情',
					hideBanner: true
				}
			},
			{
				path: 'nsqaPost',
				name: 'nsqaPost',
				component: () => import("@/view/nsqa/nsqaPost.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '农事问答提问',
					// type: 'islog'
				}
			}
		]
	},
	{
		path: '/zyfc',
		name: 'zyfc',
		component: () => import("@/view/zyfc/zyfc.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '站院风采'
		}
	},
	{
		path: '/zygx',
		name: 'resources',
		component: () => import("@/view/resources/resources.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '联建课堂'
		},
		children: [
			{
				path: 'lecture-more',
				name: 'lecture-more',
				component: () => import("@/view/resources/lecture-more.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '公益讲座更多'
				}
			},
			{
				path: 'henan-lecture-more',
				name: 'henan-lecture-more',
				component: () => import("@/view/resources/henan-lecture-more.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '河南农技大讲堂更多'
				}
			},
			{
				path: 'classroom-more',
				name: 'classroom-more',
				component: () => import("@/view/resources/classroom-more.vue"),
				// hidden: true,
				meta: {
					id: 1,
					name: '三农课堂更多'
				}
			}
		]
	},
		{
		path: '/notic',
		name: 'notic',
		component: () => import("@/view/notic/notic.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '通知公告'
		}
	},
	{
		path: '/sh',
		name: 'search',
		component: () => import("@/view/search/search.vue"),
		// hidden: true,
		meta: {
			id: 0,
			name: '联建课堂'
		}
	},
	{
		path: '/yardhome',
		name: 'yardhome',
		meta: {
			id: 3,
			name: '小院主页'
		},
		component: () => import("@/view/yard/yard.vue"),
	},
	{
		path: '/newyardhome',
		name: 'newyardhome',
		meta: {
			id: -1,
			name: '新站院详情页'
		},
		component: () => import("@/view/yard/newYard.vue"),
	},
	{
		path: '/yardnews',
		name: 'yardnews',
		component: () => import("@/view/yard/yardnews.vue"),
		meta: {
			id: 3,
			name: '小院首页'
		},
		children: [
			{
				path: 'yardnewsmore',
				name: 'yardnewsmore',
				component: () => import("@/view/yard/yardnewsmore.vue"),
				meta: {
					id: 3,
					name: '小院动态更多'
				}
			},
			{
				path: 'yardnoticemore',
				name: 'yardnoticemore',
				component: () => import("@/view/yard/yardnoticemore.vue"),
				meta: {
					id: 3,
					name: '小院通知公告更多'
				}
			},
			{
				path: 'yardsciencemore',
				name: 'yardsciencemore',
				component: () => import("@/view/yard/yardsciencemore.vue"),
				meta: {
					id: 3,
					name: '小院科学研究更多'
				}
			},
			{
				path: 'yardlogsmore',
				name: 'yardlogsmore',
				component: () => import("@/view/yard/yardlogsmore.vue"),
				meta: {
					id: 3,
					name: '站院日志更多'
				}
			},
		]
	},
	{
		path: '/yardnewsDetail/:id',
		name: 'yardnewsDetail',
		component: () => import("@/view/yard/yardnewsDetail.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院首页'
		}
	},
	{
		path: '/yardLogDetail/:id',
		name: 'yardLogDetail',
		component: () => import("@/view/yard/yardLogDetail.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院首页'
		}
	},
	
	{
		path: '/yardintro',
		name: 'yardintro',
		component: () => import("@/view/yard/yardintro.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院介绍'
		}
	},
	{
		path: '/yardspecialist',
		name: 'yardspecialist',
		component: () => import("@/view/yard/yardspecialist.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '驻站专家'
		}
	},
	{
		path: '/yardnsqa',
		name: 'yardnsqa',
		component: () => import("@/view/yard/yardnsqa.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院农事问答'
		}
	},
		{
		path: '/yardnotic',
		name: 'yardnotic',
		component: () => import("@/view/yard/yardnotic.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院通知公告'
		}
	},
	{
				path: '/yardlogsmore',
				name: 'yardlogsmore',
				component: () => import("@/view/yard/yardlogsmore.vue"),
				meta: {
					id: 3,
					name: '站院日志更多'
				}
			},
	{
		path: '/yardkepu',
		name: 'yardkepu',
		component: () => import("@/view/yard/yardkepu.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院科普'
		},
		children: [
			{
				path: 'lecture-more',
				name: 'yardkepu-lecture-more',
				component: () => import("@/view/yard/yardkepu-lecture-more.vue"),
				hidden: true,
				meta: {
					id: 3,
					name: '小院公益讲座更多'
				}
			},
			{
				path: 'henan-lecture-more',
				name: 'yardkepu-henan-lecture-more',
				component: () => import("@/view/yard/yardkepu-henan-lecture-more.vue"),
				hidden: true,
				meta: {
					id: 3,
					name: '小院河南农技大讲堂更多'
				}
			},
			{
				path: 'classroom-more',
				name: 'yardkepu-classroom-more',
				component: () => import("@/view/yard/yardkepu-classroom-more.vue"),
				hidden: true,
				meta: {
					id: 3,
					name: '小院三农课堂更多'
				}
			}
		]
	},
	{
		path: '/yardstudeng',
		name: 'yardstudeng',
		component: () => import("@/view/yard/yardstudeng.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '驻站学生'
		}
	},
	{
		path: '/yardspecialistdetail/:id',
		name: 'yardspecialistdetail',
		component: () => import("@/view/yard/yardspecialisdetail.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '驻站专家详情'
		}
	},
	{
		path: '/yardstudengdetai/:id',
		name: 'yardstudengdetai',
		component: () => import("@/view/yard/yardstudengdetai.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '驻站学生详情'
		}
	},
	{
		path: '/yardnsqaDetail/:id',
		name: 'yardnsqaDetail',
		component: () => import("@/view/yard/yardnsqaDetail.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院农事问答详情'
		}
	},
	{
		path: '/yardnsqaPost',
		name: 'yardnsqaPost',
		component: () => import("@/view/yard/yardnsqaPost.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院农事问答提问'
		}
	},
	{
		path: '/yardkepuDetail/:id',
		name: 'yardkepuDetail',
		component: () => import("@/view/yard/yardkepuDetail.vue"),
		hidden: true,
		meta: {
			id: 3,
			name: '小院科普详情'
		}
	},
	

	{
		path: '/login',
		name: 'login',
		component: () => import("@/view/login/login.vue"),
		hidden: true,
		meta: {
			id: -1,
			name: '登录'
		}
	},

	{
		path: '/uc',
		name: 'uc',
		component: () => import("@/view/login/uc.vue"),
		hidden: true,
		meta: {
			id: 1,
			name: '个人中心',
			type: 'islog'
		}
	},

	{
		path: '/register',
		name: 'register',
		component: () => import("@/view/login/register.vue"),
		hidden: true,
		meta: {
			id: -1,
			name: '注册'
		}
	},

	{
		path: '/ruzhu',
		name: 'ruzhu',
		component: () => import("@/view/login/ruzhu.vue"),
		hidden: true,
		meta: {
			id: -1,
			name: '入驻登记'
		}
	},
	
	

	// {
	// 	path: '/search',
	// 	name: 'search',
	// 	component: () => import("@/view/search/search.vue"),
	// 	hidden: true,
	// 	meta: {
	// 		id: 2,
	// 		name: '搜索'
	// 	}
	// },
	// {
	// 	path: '/userCenter',
	// 	name: 'userCenter',
	// 	component: () => import("@/view/userCenter/userCenter.vue"),
	// 	hidden: true,
	// 	meta: {
	// 		id: 2,
	// 		name: '个人中心',
	// 		type:'islog'
	// 	},
	// 	children: [
	// 		{
	// 			path: '/leaveList',
	// 			name: 'leaveList',
	// 			component: () => import("@/view/userCenter/leaveList.vue"),
	// 			hidden: true,
	// 			meta: {
	// 				id: 2,
	// 				name: '请假申请',
	// 				icon1:1
	// 			},
	// 		},
	// 	]
	// },
]
const router = createRouter({
	history: createWebHashHistory(),
	routes
})

router.beforeEach((to,from,next)=> {
	if(!localStorage.getItem('userInfo_keji')){
		if (to.meta.name == '登录'){
			next()
		} else{
			if (to.meta.type == 'islog'){
				ElMessage.error('请先登录')
				next({
				    path: '/home',
				});
				return;
			} else{
				next()
			}
		}
	}else{
		next()
	}
	// if(to.meta.name == 'Space' || to.meta.name == 'Exams'){
	// 	if(localStorage.getItem('username')){
	// 		next()
	// 	}else{
	// 		ElMessage.error('请先登录')
	// 		// next({
	// 		//     path: '/home',
	// 		// });
	// 		return;
	// 	}
	// }else{
	// 	next()
	// }
})
export default router